<div class="layui-side layui-bg-black">
	<div class="layui-side-scroll">
		<#include "/apps/business/contacts/include/leftmenu.html">
	</div>
</div>
<div class="layui-body">
	<#include "/apps/business/contacts/include/head.html">
	<div class="layui-tab">
	  <div class="layui-tab-content" style="padding:0px;">
	    <div class="layui-tab-item layui-show">
			<div class="layui-side-scroll">
				<form class="layui-form" name="search" action="/apps/contacts/<#if typename??>${typename!}<#else>index</#if>.html?contactstype=${contactstype!''}" method="post">
					<div class="row">
						<div class="col-lg-12">
							<h1 class="site-h1" >
							筛选条件
								<div class="ukefu-bt-text-content" style="position: absolute;right: 5px;top: 0px;">
									<button class="layui-btn layui-btn-sm" type="submit">
										<i class="layui-icon">&#xe615;</i> 
										查询
									</button>
									<a href="javascript:void(0)" class="layui-btn layui-btn-sm" id="morebtn" data-btn="0" >
										<i class="layui-icon" id="moreicon">&#xe61a;</i> 
										展开更多
									</a>
								</div>
							</h1>
						</div>
					</div>
					<div class="row">
						<div class="col-lg-11">
							<#if itemid??><input type="hidden" name="itemid" value="${itemid!''}"></#if>
							<#if ckind??><input type="hidden" name="ckind" value="${ckind!''}"></#if>
			    			<#include "/apps/business/contacts/include/search.html">
						</div>
					</div>
				</form>
				<div class="row" >
					<div class="col-lg-12">
						<h1 class="site-h1" style="border-top: 1px solid #eee;">
							联系人列表<#if contactsList??>（${contactsList.totalElements!''}）</#if>
							<div class="ukefu-bt-text-content" style="position: absolute;right: 5px;top: 0px;">
								<#if models?? && models["sales"]?? && models["sales"] == true && typename != "disagent">
									<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B12"]?? || user.usertype == "0")) >
										<#if contactsList?? && contactsList.totalElements gt 0>
										<div class="layui-btn-group ukefu-btn-group ukefu-contacts-h1-btn" >
											<button class="layui-btn layui-btn-sm dropdown-menu">
												<i class="kfont">&#xe672;</i> 分配 
												<i class="layui-icon">&#xe625;</i>
											</button>
											<ul class="ukefu-dropdown-menu layui-anim layui-anim-upbit">
												<#if ckind??>
												<li>
													<a href="/apps/contacts/dis.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if><#if organ??>&organ=${organ!''}</#if>" title="分配当前分类" data-toggle="ajax" data-width="950" data-height="650" >
														<i class="kfont">&#xe672;</i>
														分配当前分类
													</a>
												</li>
												</#if>
												<li>
													<a href="/apps/contacts/dis.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if><#if filterCriteria??>&filter=${filterCriteria}</#if><#if organ??>&organ=${organ!''}</#if>" title="分配当前筛选" data-toggle="ajax" data-width="950" data-height="650" >
														<i class="kfont">&#xe672;</i>
														分配当前筛选
													</a>
												</li>
												<li>
													<a href="javascript:void(0)" id="dischecked" title="分配当前筛选" data-toggle="ajax" data-width="950" data-height="650">
														<i class="kfont">&#xe672;</i>
														分配选中项
													</a>
												</li>
											</ul>
										</div>
										</#if>
									</#if>
								</#if>
								<#if models?? && models["sales"]?? && models["sales"] == true && maintype=="contacts" && (typename == "disagent" || typename == "disorgan")>
									<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B13"]?? || user.usertype == "0")) >
										<div class="layui-btn-group ukefu-btn-group ukefu-contacts-h1-btn" >
											<button class="layui-btn layui-btn-sm dropdown-menu">
												<i class="kfont">&#xe672;</i> 回收
												<i class="layui-icon">&#xe625;</i>
											</button>
											<ul class="ukefu-dropdown-menu layui-anim layui-anim-upbit">
												<!-- <li>
													<a href="/apps/contacts/recycle.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if>"  data-toggle="tip" title="是否回收当前分类？">
														<i class="kfont">&#xe672;</i>
														回收当前分类
													</a>
												</li> -->
												<li>
													<a href="/apps/contacts/recycle.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if><#if filterCriteria??>&filter=${filterCriteria}</#if>" title="是否回收当前筛选?" data-toggle="tip" >
														<i class="kfont">&#xe672;</i>
														回收当前筛选
													</a>
												</li>
												<li>
													<a href="javascript:void(0)" id="recyclechecked" title="请确认是否回收选中的联系人？" data-toggle="tip">
														<i class="kfont">&#xe672;</i>
														回收选中项
													</a>
												</li>
											</ul>
										</div>
									</#if>
								</#if>
							</div>
						</h1>
						<div class="row" style="padding:5px;">
							<div class="col-lg-12">
								<table class="layui-table" lay-skin="line" >
									<thead>
										<tr class="design-sortable-tr">
											<th>
												<input type="checkbox" id="all" onclick="$('.ids').prop('checked' , $(this).prop('checked'));"/>
											</th>
											<th nowrap="nowrap">联系人姓名</th>
											<!-- <th nowrap="nowrap">客户姓名</th> -->
											<th nowrap="nowrap">手机号</th>
											<!-- <th nowrap="nowrap">微信号</th> -->
											<th nowrap="nowrap">联系人状态</th>
											<th nowrap="nowrap">城市</th>
											<th nowrap="nowrap">性别</th>
											<th nowrap="nowrap">分配</th>
											<th nowrap="nowrap">拨打</th>
											<th nowrap="nowrap">项目</th>
											<!-- <th nowrap="nowrap">备注</th> -->
											<!-- <th nowrap="nowrap">创建时间</th> -->
											<th nowrap="nowrap">更新时间</th>
											<!-- <th nowrap="nowrap">拨打状态</th> -->
											<!-- <th nowrap="nowrap">分配状态</th> -->
											<th nowrap="nowrap">业务状态</th>
											<th nowrap="nowrap">处理人</th>
											<th nowrap="nowrap">创建人</th>
											<th nowrap="nowrap">操作</th>
										</tr>
									</thead>
									<tbody>
										<#if contactsList?? && contactsList.content?? && contactsList.content?size gt 0>
										<#list contactsList.content as contacts>
										<tr class="tdHasContorllor design-dropable-td">
											<td style="width:1%;">
												<input type="checkbox" class="ids" name="ids" value="${contacts.id!''}"/>
											</td>
											<td width="15%">
												<a href="javascript:void(0)" onclick="return false;" data-toggle="tab" data-title="<#if contacts?? && contacts.ctype == 'contacts'>联系人<#elseif contacts?? && contacts.ctype == 'customer'>客户<#else>联系人</#if>（${contacts.name!''}）" data-href="/apps/contacts/view.html?id=${contacts.id!''}"  data-id="contacts${contacts.id!''}" data-type="tabAdd">
													<i class="layui-icon headimg" title="<#if contacts?? && contacts.ctype=='contacts'>联系人<#elseif contacts?? && contacts.ctype=='customer'>客户</#if>（${contacts.name!''}）,获得时间：<#if contacts.touchtime??>${contacts.touchtime?string("yyyy-MM-dd")}</#if>">&#xe612;</i>
													<div style="margin-left:50px;margin-top:0px;">
														<#if contacts.name?? && contacts.name != "">${contacts.name!''}<#else>未知</#if>
													</div>
													<div title="动态" style="margin-left:50px;margin-top:0px;color:#cccccc;font-size:13px;position: absolute;width: 300px;">
														<#if contacts.salesmemo?length gt 10>
															${contacts.salesmemo[0..10]?no_esc}...
														<#else>
															${(contacts.salesmemo!'')?no_esc}
														</#if>
														<#if contacts.busmemo?length gt 20>
															${contacts.busmemo[0..20]?no_esc}...
														<#else>
															${(contacts.busmemo!'')?no_esc}
														</#if>
													</div>
												</a>
											</td>
											<!-- <td>${contacts.cusname!''}</td> -->
											<td>
												<#if contacts.mobileno?? && contacts.mobileno!="">
												<div class="ukefu-phone-number" data-type="contacts" data-id="${contacts.id!''}">
												${contacts.mobileno!''} 
												</div>
												</#if>
											</td>
											
											<!-- <td>
												${contacts.weixin!''} 
											</td> -->
											
											<td>
												<!-- <#if saleStatusList?? && saleStatusList?size gt 0><#list saleStatusList as saleStatus><#if saleStatus.id==contacts.salestatus>${saleStatus.name!''}</#if></#list></#if> -->
												${uKeFuDic[contacts.business!''].name!''}
											</td>
											<td nowrap="nowrap" title="${uKeFuDic[contacts.province!''].name!''} / ${uKeFuDic[contacts.city!''].name!''} / ${uKeFuDic[contacts.area!''].name!''}">
												<#if uKeFuDic[contacts.city!''].name??>${uKeFuDic[contacts.city!''].name!''}<#else>${uKeFuDic[contacts.province!''].name!''}</#if>
											</td>
											<td>
												<#if contacts.gender=="1">男<#elseif contacts.gender=="0">女<#else>未知</#if>
											</td>
											<td>
												<#if contacts.status?? && (contacts.status == "disagent" || contacts.status == "disorgan")>
													<i class="layui-icon" style="color:#19a55d;" title="${contacts.jobname!''}">&#xe605;</i>
												</#if>
											</td>
											<td>
												<#if contacts.callstatus?? && contacts.callstatus == "called" && contacts.workstatus?? && contacts.workstatus == "success">
													<i class="layui-icon" style="color:#19a55d;" title="拨打成功：${contacts.calltime!''}，拨打时间：${contacts.calltime?number?number_to_datetime}">&#xe605;</i>
												<#elseif contacts.callstatus?? && contacts.callstatus == "called" && contacts.workstatus?? && contacts.workstatus == "faild">
													<i class="layui-icon" style="color:red;" title="拨打失败：${contacts.calltime!''}，拨打时间：${contacts.calltime?number?number_to_datetime}">&#x1006;</i>
												</#if>
											</td>
											<td>
												<#if contactsItem??>${contactsItem.name!''}
												<#elseif contactsItemList?? && contactsItemList?size gt 0>
													<#list contactsItemList as items>
														<#if items.id==contacts.itemid>${items.name!''}</#if>
													</#list>
												</#if>
											</td>
											<!-- <td nowrap="nowrap">
												<#if contacts.memo?? && contacts.memo?length gt 30>${contacts.memo[0..30]}<#else>${contacts.memo!''}</#if>
											</td> -->
											<!-- <td nowrap="nowrap">
												<#if contacts.createtime??>${contacts.createtime?string("yyyy-MM-dd HH:mm:ss")}</#if>
											</td> -->
											<td nowrap="nowrap">
												<#if contacts.updatetime??>${contacts.updatetime?string("yyyy-MM-dd HH:mm:ss")}</#if>
											</td>
											<!-- <td>
												<#if contacts.callstatus??>
													<#if contacts.callstatus == 'called'>
														已拨打
													<#elseif contacts.callstatus == 'notcall'>
														未拨打
													<#elseif contacts.callstatus == 'waste'>
														已作废
													<#else>
														${contacts.callstatus!''}
													</#if>
												</#if>
											</td> -->
											<!-- <td>
												${contacts.status!''}
											</td> -->
											<td><#if saleStatusList?? && saleStatusList?size gt 0><#list saleStatusList as saleStatus><#if saleStatus.id==contacts.salestatus>${saleStatus.name!''}</#if></#list></#if></td>
											<td>
											<!-- 
											<#if uKeFuDic[contacts.cusvalidstatus!'']??>
												${uKeFuDic[contacts.cusvalidstatus!''].name!''}
											<#else>
												${contacts.cusvalidstatus!''}
											</#if>
											
											</td>
											 -->
											<td>
												<#if allUserList??>
													<#list allUserList as user>
														<#if user.id==contacts.owneruser>${user.username!''}</#if>
													</#list>
												</#if>
											</td>
											
											<td style="white-space:nowrap;width:1%;" nowrap="nowrap">
												<#if maintype=="contacts" && typename == "disorgan" && contacts?? && contacts.owneruser==''>
													<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B25"]?? || user.usertype == "0")) >
													<a href="/apps/contacts/receive.html?id=${contacts.id!''}&itemid=${itemid!''}&ckind=${ckind!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否领取该联系人？">
										  				<i class="kfont">&#xe654;</i>
											  			领取
											  		</a>
											  		</#if>
												</#if>
												<#if models?? && models["sales"]?? && models["sales"] == true && typename != "quality">
												<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B18"]?? || user.usertype == "0")) >
												<a href="/apps/contacts/reservation/add.html?contactsid=${contacts.id!''}&statusCode=${contactsItem.statuscode!''}&itemid=${itemid!''}&ckind=${ckind!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>" data-toggle="ajax" data-width="750" data-height="400" data-title="预约">
										  			<i class="kfont"></i>
										  			状态
										  		</a>
										  		</#if>
												</#if>
												<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B06"]?? || user.usertype == "0")) >
										  		<a href="/apps/contacts/edit.html?id=${contacts.id!''}&itemid=${itemid!''}&ckind=${ckind!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>&contactstype=${contactstype!''}&nowUrl=${nowUrl!''}" data-toggle="ajax" data-width="950" data-height="600" data-title="编辑联系人信息">
										  			<i class="layui-icon">&#xe642;</i>
										  			编辑
										  		</a>
										  		</#if>
										  		<!-- <a href="/apps/contacts/delete.html?id=${contacts.id!''}&itemid=${itemid!''}&ckind=${ckind!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否删除联系人？">
										  			<i class="layui-icon" style="color:red;">&#x1006;</i>
										  			删除
										  		</a> -->
										  		<#if  maintype=="contacts" && typename == "quality">
										  			<#if (isSup?? && isSup) || (user?? && user.superuser) || (user?? && (user.roleAuthMap["A02_A01_A02_B24"]?? || user.usertype == "0")) >
										  			<a href="/apps/contacts/quality/add.html?contactsid=${contacts.id!''}&itemid=${itemid!''}&ckind=${ckind!''}&statusCode=${contactsItem.statuscode!''}&qualitystatus=${qualitystatus!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>" data-toggle="ajax" data-width="950" data-height="700" data-title="质检信息">
											  			<i class="kfont"	style="position: relative;">&#xe656;</i>
											  			质检
											  		</a>
											  		</#if>
										  		</#if>
										  </td>
										</tr>
										</#list>
										<#else>
											<tr>
												<td colspan="20" style="height:400px;">
													<div class="ukefu-empty">
														<i class="layui-icon">&#xe63a;</i>
														<div style="">还没有联系人信息</div>
													</div>
												</td>
											</tr>
										</#if>
									</tbody>
								</table>
							</div> 	   
						</div>
						<div class="row" style="padding:5px;">
							<div class="col-lg-12" id="page" style="text-align:center;"></div>
						</div>
					</div>	
				</div>
			</div>
		</div>
	</div>
</div>
<script>
$(document).ready(function(){
	$(".menu-dropdown-a").click(function(){
		  var objpage = $(this).parent().children(".page-list") ;
		  if(objpage.css("display")=="none"){
			  objpage.show();
		  }else{
			  objpage.hide();
		  }
	  });
	$('#batexp').click(function(){
		var ids = "";
		var num = 0 ;
		$('.ids').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				ids += "ids=" + $(this).val();
				num++;
			}
		});
		if(num>0){
			$('#batexp').attr('href' , '/apps/contacts/expids.html?'+ids)	;
		}else{
			top.layer.alert("请先选择需要导出的联系人信息");
			$('#batexp').attr("href" , "javascript:void(0)");
		}
	});
	$('#batdel').click(function(){
		var ids = "";
		var num = 0 ;
		$('.ids').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				ids += "ids=" + $(this).val();
				num++;
			}
		});
		if(num>0){
			$('#batdel').attr('href' , '/apps/contacts/batdel.html?itemid=${itemid!''}&ckind=${ckind!''}&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>&'+ids)	;
		}else{
			top.layer.alert("请先选择需要删除的联系人信息");
			$('#batdel').attr("href" , "javascript:void(0)");
		}
	});
	$('#searchdel').click(function(){
		$('#searchdel').attr('href' , '/apps/contacts/search/del.html?itemid=${itemid!''}&ckind=${ckind!''}&contactstype=${contactstype!''}<#if filterCriteria??>&filter=${filterCriteria}</#if>&p=<#if contactsList??>${contactsList.number+1}<#else>0</#if>')	;
	});
	$('#dischecked').click(function(){
		var ids = "";
		var num = 0 ;
		$('.ids').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				ids += "ids=" + $(this).val();
				num++;
			}
		});
		if(num>0){
			$('#dischecked').attr('href' , '/apps/contacts/dis.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if><#if filterCriteria??>&filter=${filterCriteria}</#if><#if organ??>&organ=${organ!''}</#if>&'+ids)	;
		}else{
			top.layer.alert("请先选择需要分配的联系人");
			$('#dischecked').attr("href" , "javascript:void(0)");
		}
	});
	$('#recyclechecked').click(function(){
		var ids = "";
		var num = 0 ;
		$('.ids').each(function(){
			if($(this).prop("checked")){
				if(ids!=""){
					ids += "&" ;
				}
				ids += "ids=" + $(this).val();
				num++;
			}
		});
		if(num>0){
			$('#recyclechecked').attr('href' , '/apps/contacts/recycle.html?size=${contactsList.totalElements}<#if itemid??>&itemid=${itemid}<#elseif ckind??>&ckind=${ckind}</#if><#if filterCriteria??>&filter=${filterCriteria}</#if>&'+ids)	;
		}else{
			top.layer.alert("请先选择需要回收的联系人");
			$('#recyclechecked').attr("href" , "javascript:void(0)");
		}
	});
});
layui.use(['laypage', 'layer'], function(){
	  var laypage = layui.laypage
	  ,layer = layui.layer;
	  
	  laypage.render({
			elem: 'page'
			,pages: <#if contactsList??>${contactsList.totalPages}<#else>0</#if> //总页数
			,curr:<#if contactsList??>${contactsList.number+1}<#else>0</#if>
			,groups: 5 //连续显示分页数
			,jump:function(data , first){
				if(!first){
					location.href = "/apps/contacts/${subtype!'index'}.html?p="+data.curr
					+"&itemid=${itemid!''}&ckind=${ckind!''}&qualitystatus=${qualitystatus!''}&hangupcase=${hangupcase!''}&contactstype=${contactstype!''}"
					+"<#if name??>&name=${name!''}</#if>"
					+"<#if statusCode??>&statusCode=${statusCode!''}</#if>"
					+"<#if weixin??>&weixin=${weixin!''}</#if>"
					+"<#if mobileno??>&mobileno=${mobileno!''}</#if>"
					+"<#if touchtimebegin??>&touchtimebegin=${touchtimebegin!''}</#if>"
					+"<#if touchtimeend??>&touchtimeend=${touchtimeend!''}</#if>"
					+"<#if incallbegin??>&incallbegin=${incallbegin!''}</#if>"
					+"<#if incallend??>&incallend=${incallend!''}</#if>"
					+"<#if updatetimebegin??>&updatetimebegin=${updatetimebegin!''}</#if>"
					+"<#if updatetimeend??>&updatetimeend=${updatetimeend!''}</#if>"
					+"<#if salesmemo??>&salesmemo=${salesmemo!''}</#if>"
					+"<#if owneruser??>&owneruser=${owneruser!''}</#if>"
					+"<#if business??>&business=${business!''}</#if>"
					+"<#if busmemo??>&busmemo=${busmemo!''}</#if>"
					+"<#if reservation??>&reservation=${reservation!''}</#if>"
					+"<#if reservtype??>&reservtype=${reservtype!''}</#if>"
					+"<#if optimebegin??>&optimebegin=${optimebegin!''}</#if>"
					+"<#if optimeend??>&optimeend=${optimeend!''}</#if>"
					+"<#if email??>&email=${email!''}</#if>"
					+"<#if address??>&address=${address!''}</#if>"
					+"<#if province??>&province=${province!''}</#if>"
					+"<#if city??>&city=${city!''}</#if>"
					+"<#if ctype??>&ctype=${ctype!''}</#if>"
					+"<#if creater??>&creater=${creater!''}</#if>"
					+"<#if ckinds??>&ckinds=${ckinds!''}</#if>"
					+"<#if gender??>&gender=${gender!''}</#if>"
					+"<#if cusname??>&cusname=${cusname!''}</#if>"
					+"<#if cusphone??>&cusphone=${cusphone!''}</#if>"
					+"<#if cusemail??>&cusemail=${cusemail!''}</#if>"
					+"<#if cusaddress??>&cusaddress=${cusaddress!''}</#if>"
					+"<#if cusprovince??>&cusprovince=${cusprovince!''}</#if>"
					+"<#if cuscity??>&cuscity=${cuscity!''}</#if>"
					+"<#if ekind??>&ekind=${ekind!''}</#if>"
					+"<#if elevel??>&elevel=${elevel!''}</#if>"
					+"<#if esource??>&esource=${esource!''}</#if>"
					+"<#if maturity??>&maturity=${maturity!''}</#if>"
					+"<#if industry??>&industry=${industry!''}</#if>"
					+"<#if cusvalidstatus??>&cusvalidstatus=${cusvalidstatus!''}</#if>";
				}
			}
	   });
	});
</script>
